# Required function: `strs.alloc.n` towns=read.csv('http://www.webpages.uidaho.edu/%7Erenaes/Data/tvtowns1.csv',header=T) boxplot(towns$Hours.TV~towns$Town,main='Hours of TV by Town') Ni=c(93,155,62); B=2 cost=c(9,9,16); fcost=500 # if you are using existing variances, you can with the following code # s2i=tapply(towns$Hours.TV,towns$Town,var,na.rm=T) # we are using other estimates of variances s2i=c(100,25,225) # Optimal alloc.n('tvtime',towns$Town,Ni,s2i,cost,fcost,'optimal','mean',B) # Neyman alloc.n('tvtime',towns$Town,Ni,s2i,cost,fcost,'Neyman','mean',B) # proportional # this example also assumes equal standard deviations of 10 vars=c(100,100,100) # or vars=rep(10^2,3) alloc.n('tvtime',towns$Town,Ni,vars,cost,fcost,'proportional','mean',B) # Fixed cost alloc.n('tvtime',towns$Town,Ni,s2i,cost,fcost,'fixed','mean',B)